package com.yuma.reffunc;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

public class DynamicFunctionRefDemo {
    public static void main(String[] args) {
        String str = "hello world";

        Supplier<Boolean> s1 = str::isBlank;
        System.out.println(s1.get());  // str.isBlank();

        Function<String,Boolean> s2 = str::contains;
        System.out.println(s2.apply("hello"));  // str.contains("hello");

        List<String> list = List.of("hello world", "hello", "world");
        List<String> emptyList = new ArrayList<>();
        // Consumer void apply(T) = boolean list.add(t)  会丢弃返回值
        list.stream().forEach(emptyList::add);
        System.out.println(emptyList);

    }
}
